<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<script src="js/mui.min.js"></script>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/iconfont.css" rel="stylesheet" />
		<link href="css/home.css" rel="stylesheet" />
		<link href="css/common.css" rel="stylesheet" />
		<style>

		</style>

	</head>
	<body>
		<nav class="mui-bar mui-bar-tab touch-action">
			<a class="mui-tab-item mui-active " pageid="homepage">
				<span class="mui-icon iconfont icon-shouye"></span>
				<span class="mui-tab-label">首页</span>
			</a>
			<a class="mui-tab-item" pageid="infopage">
				<span class="mui-icon iconfont icon-zixun"></span>
				<span class="mui-tab-label">资讯</span>
			</a>
			<a class="mui-tab-item" pageid="propage">
				<span class="mui-icon iconfont icon-fenxiang"></span>
				<span class="mui-tab-label">分享</span>
			</a>
			<a class="mui-tab-item" url="me.html" pageid="mepage">
				<span class="mui-icon iconfont icon-wode"></span>
				<span class="mui-tab-label">我的</span>
			</a>
		</nav>

		<script type="text/javascript" charset="utf-8">
			function checkLogin() {
				console.log("check");
				//判断是否已经登录;
				var ltoken = localStorage.logintoken;
				//ltoken="undefined";
				console.log(typeof(ltoken));
				console.log(ltoken == "null");
				if (!ltoken || ltoken == "null" || ltoken == "undefined") {
					//没登录,打开登录页
					console.log("ltoken值为空");
					var indexpage = plus.webview.currentWebview();

					var login_win = plus.webview.create("login.html", "login");
					login_win.show();
					indexpage.close();

					return false;
				}
			}
			mui.init({
				keyEventBind: {
					backbutton: false, //Boolean(默认true)关闭back按键监听
					menubutton: false //Boolean(默认true)关闭menu按键监听
				},
				swipeBack: true,
				beforeback: function() {//监听用户侧滑手势
					plus.nativeUI.confirm("确认退出APP？", function(e) {
						console.log("Close confirm: " + e.index);
						if (e.index == 0) {
							plus.runtime.quit();
						}
					});
					return false;
				}
			});

			mui.plusReady(function() {

				console.log('plusReady');
				var islogin = checkLogin();
				if (islogin == false) {
					return false;
				}

				//设置状态栏的颜色
				plus.navigator.setStatusBarStyle("UIStatusBarStyleBlackOpaque");
				plus.navigator.setStatusBarBackground('#1b99dc');

				var pageurls = ["html/home.html", "html/info.html", "html/pro.html", "html/me.html"];
				var pageids = ["homepage", "infopage", "propage", "mepage"]


				var cw = plus.webview.currentWebview()
				for (var i = 0; i < pageurls.length; i++) {
					var item = plus.webview.create(pageurls[i], pageids[i], {
						top: "0px",
						bottom: "50px"
					})
					cw.append(item);
				}
				plus.webview.show('homepage');

				//cw.show("homepage");

				mui(".mui-bar-tab").on('tap', 'a', function() {

					var pageid = this.getAttribute("pageid");
					plus.webview.show(pageid);
				})


			})
		</script>

	</body>
</html>
